/**
 * 
 */
package com.app.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.app.dao.ICompetenceDao;
import com.app.dao.po.CornCompetence;
import com.app.service.vo.CornCompetenceVo;

/**
 * @author Administrator
 *
 */
public class CompetenceDaoImpl extends HibernateDaoSupport implements
		ICompetenceDao {

	/**
	 * 
	 */
	public CompetenceDaoImpl() {
		// TODO Auto-generated constructor stub
		logger.info(this.getClass()+" loader");
	}
	
	private static Logger logger = Logger.getLogger(CompetenceDaoImpl.class);

	/* (non-Javadoc)
	 * @see com.app.dao.ICompetenceDao#getAllComptence()
	 */
	@Override
	public List<CornCompetenceVo> getAllComptence() {
		// TODO Auto-generated method stub
		List<CornCompetenceVo> volist = new ArrayList<CornCompetenceVo>();
		List<CornCompetence> polist = this.getHibernateTemplate().loadAll(CornCompetence.class);
		for(CornCompetence po:polist)
		{
			volist.add((CornCompetenceVo)new CornCompetenceVo().parseVo(po));
		}
		return volist;
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICompetenceDao#addCompetence(com.app.service.vo.CornCompetenceVo)
	 */
	@Override
	public void addCompetence(CornCompetenceVo vo) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().save(vo.parsePo(new CornCompetence()));
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICompetenceDao#updateCompetence(com.app.service.vo.CornCompetenceVo)
	 */
	@Override
	public void updateCompetence(CornCompetenceVo vo) {
		// TODO Auto-generated method stub
		
		this.getHibernateTemplate().update(vo.parsePo(new CornCompetence()));
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICompetenceDao#deleteCompetence(com.app.service.vo.CornCompetenceVo)
	 */
	@Override
	public void deleteCompetence(CornCompetenceVo vo) {
		// TODO Auto-generated method stub
		CornCompetence po = this.getHibernateTemplate().get(CornCompetence.class, vo.getId());
		this.getHibernateTemplate().delete(po);
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICompetenceDao#getCompetenceVoById(java.lang.String)
	 */
	@Override
	public CornCompetenceVo getCompetenceVoById(String id) {
		// TODO Auto-generated method stub
		return (CornCompetenceVo) new CornCompetenceVo().parseVo(this.getHibernateTemplate().get(CornCompetence.class, id));
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICompetenceDao#getCompetenceVoBySql(java.lang.String)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<CornCompetenceVo> getCompetenceVoBySql(String sql) {
		// TODO Auto-generated method stub
		List<CornCompetenceVo> volist = new ArrayList<CornCompetenceVo>();
		List<CornCompetence> polist = this.getHibernateTemplate().find(sql);
		for(CornCompetence po:polist)
		{
			volist.add((CornCompetenceVo) new CornCompetenceVo().parseVo(po));
		}
		return volist;
	}

}
